const mongo=require("mongodb")
const MongoClient=mongo.MongoClient
const dburl="mongodb://localhost:27017"

let storeDB
function getStoreDB(callback){
    if(storeDB){
        callback(storeDB)
        return
    }
    MongoClient.connect(dburl,function(err,client){
        if(err){
            console.log(err)
            return
        }
        const storeDB= client.db("store")
        callback(storeDB)
    })
}
module.exports={
    getStoreDB
}
